<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    *{
        margin:0;
        padding: 0;
    }
    ul{
        width: 200px;
        margin: 0 auto;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: azure;
    }
    ul li {
        list-style: none;
        width: 60px;
        background-color: aqua;
     
        text-align: center;
        position: relative;
    }
    a{
        text-decoration: none;   color: rgb(230, 35, 68);
    }
    ul li div{
        display: none;
        text-align: center;
        width: 60px;
        background-color: blanchedalmond;
        position: absolute;
    }
    ul li div a {
        width: 60px;
        height: 20px;
        display: block;
    }
    .active{
        display: block;
    }
</style>
<body>
    <ul>
        <li><a href="">水果</a><div class="active"><a href="">水果</a><a href="">水果</a><a href="">水果</a></div></li>
        <li><a href="">动物</a><div ><a href="">ren</a><a href="">re</a><a href="">水果</a></div></li>
        <li><a href="">傻子</a><div ><a href="">12</a><a href="">123</a><a href="">123</a></div></li>
    </ul>
    <script>
        var lis = document.getElementsByTagName('li')
        var box = document.getElementsByTagName('div')
        var as= document.getElementsByTagName('a')
        console.log(as);
        for(var i = 0;i<lis.length;i++){
            lis[i].onmouseenter=function(){
                for(var k =0;k<box.length;k++){
                    box[k].className=''  
                
                }
              this.lastElementChild.className='active'
            }
            lis[i].onmouseleave=function(){
                this.lastElementChild.className=''
            }
        }
    </script>
</body>
</html>